package com.homepage.domain;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.io.Serializable;

/**
 * A Featurette.
 */
@Entity
@Table(name = "featurette")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Getter
@Setter
@ToString
public class Featurette implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Long id;

    @NotNull
    @Size(max = 30)
    @Column(name = "main_title", length = 30, nullable = false)
    private String mainTitle;

    @NotNull
    @Size(max = 60)
    @Column(name = "subtitle", length = 60, nullable = false)
    private String subtitle;

    @NotNull
    @Size(max = 300)
    @Column(name = "bulletin", length = 300, nullable = false)
    private String bulletin;

    @ManyToOne
    @JsonIgnoreProperties(value = { "employees", "featurettes", "headlines", "partners", "companyLogo" }, allowSetters = true)
    private Company company;


    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof Featurette)) {
            return false;
        }
        return id != null && id.equals(((Featurette) o).id);
    }

    @Override
    public int hashCode() {
        return getClass().hashCode();
    }

}
